home *** CD-ROM | disk | FTP | other *** search
- #define NAME "testXpkMasterPrefsSem"
- #define REVISION "6"
-
- /* Programmheader
-
- Name: testXpkMasterPrefsSem
- Author: SDI
- Distribution: PD
- Description: tests "« XpkMasterPrefs »" Semaphore work
- Compileropts: -
- Linkeropts: -
-
- 1.0 25.12.96 : first Version
- 1.1 26.12.96 : xpkprefs.h changed nearly totally
- 1.2 27.12.96 : reduced length of Forbid()/Permit()
- 1.3 28.02.97 : semaphore style changed
- 1.4 01.03.97 : XpkMainPrefs changed a bit
- 1.5 24.03.97 : error fix
- 1.6 02.04.97 : changed the XpkTypeData structure
- */
-
- #include <pragma/exec_lib.h>
- #include <pragma/dos_lib.h>
- #include <exec/memory.h>
- #include "SDI_defines.h"
- #include "PrintFlags.c"
- #include <xpk/xpkprefs.h>
-
- /* This is a XpkMasterPrefs private structure !!!!! */
-
- struct XpkTypeNode {
- struct Node xtn_Node;
- ULONG xtn_Size;
- struct XpkTypePrefs xtn_TypePrefs;
- };
-
- void WriteXpkTypeData(struct XpkTypeData *xp)
- {
- STRPTR a = 0;
-
- PutStr("xtd_Flags : ");
- {
- ULONG i = xp->xtd_Flags;
- PrintFlag(&i, XTD_NoPack, "XTD_NoPack");
- PrintFlag(&i, XTD_ReturnError, "XTD_ReturnError");
- PrintEndFlag(i, xp->xtd_Flags);
- }
- a = (STRPTR) &xp->xtd_StdID;
- VPrintf("xtd_StdID : %lx", a);
- VPrintf(" (%.4s)\n", &a);
- VPrintf(
- "xtd_ChunkSize : %ld\n"
- "xtd_Mode : %d\n"
- "xtd_Version : %d\n"
- "xtd_Password : %s\n", &xp->xtd_ChunkSize);
- }
-
- void WriteXpkTypePrefs(struct XpkTypePrefs *xp)
- {
- PutStr("xtp_Flags : ");
- {
- ULONG i = xp->xtp_Flags;
- PrintFlag(&i, XPKT_NamePattern, "XPKT_NamePattern");
- PrintFlag(&i, XPKT_FilePattern, "XPKT_FilePattern");
- PrintEndFlag(i, xp->xtp_Flags);
- }
- VPrintf(
- "xtp_TypeName : %s\n"
- "xtp_NamePattern : %s\n"
- "xtp_FilePattern : %s\n"
- "xtp_PackerData :\n", &xp->xtp_TypeName);
- WriteXpkTypeData(xp->xtp_PackerData);
- }
-
- void WriteXpkMainPrefs(struct XpkMainPrefs *xp)
- {
- VPrintf("xmp_Version : %ld\n", &xp->xmp_Version);
- PutStr("xmp_Flags : ");
- {
- ULONG i = xp->xmp_Flags;
- PrintFlag(&i, XPKM_UseXFD, "XPKM_UseXFD");
- PrintFlag(&i, XPKM_AutoPassword, "XPKM_AutoPassword");
- PrintFlag(&i, XPKM_UseExternals, "XPKM_UseExternals");
- PrintEndFlag(i, xp->xmp_Flags);
- }
- PutStr("xmp_DefaultType :\n");
- WriteXpkTypeData(xp->xmp_DefaultType);
- VPrintf("xmp_Timeout : %d\n", &xp->xmp_Timeout);
- }
-
- ULONG main(void)
- {
- struct XpkPrefsSemaphore *sem;
-
- Forbid();
- if((sem = (struct XpkPrefsSemaphore *) FindSemaphore(XPKPREFSSEMNAME)))
- ObtainSemaphoreShared((struct SignalSemaphore *) sem);
- Permit();
-
- if(sem)
- {
- VPrintf("xps_Version : %ld\n", &sem->xps_Version);
- {
- STRPTR b;
- b = (STRPTR) &sem->xps_PrefsType;
- VPrintf("xps_PrefsType : %lx", b);
- VPrintf(" (%.4s)\n", &b);
- }
- VPrintf("xps_RecogSize : %ld\n", &sem->xps_RecogSize);
-
- if(sem->xps_MainPrefs)
- {
- WriteXpkMainPrefs(sem->xps_MainPrefs);
- PutStr("\n");
- }
-
- if(sem->xps_PrefsType == XPREFSTYPE_STANDARD)
- {
- struct Node *n;
- n = ((struct List *) sem->xps_PrefsData)->lh_Head;
-
- for(;n->ln_Succ && !CTRL_C; n = n->ln_Succ)
- {
- WriteXpkTypePrefs(&((struct XpkTypeNode *) n)->xtn_TypePrefs);
- PutStr("\n");
- }
- }
- ReleaseSemaphore((struct SignalSemaphore *) sem);
- }
- else
- PutStr(XPKPREFSSEMNAME " Semaphore not found.\n");
- }
-